
public class GeometryUnion extends Geometry {
	public Geometry[] geometries;
	
	public GeometryUnion(Geometry[] g)
	{
		geometries = g;
	}
	
	@Override
	public IntersectResult intersect(Ray3 ray)
	{
		double minDistance = Double.MAX_VALUE;
		IntersectResult minResult = new IntersectResult();
		for(Geometry g : geometries)
		{
			IntersectResult result = g.intersect(ray);
			if(result.geometry != null && result.distance < minDistance)
			{
				minDistance = result.distance;
				minResult = result;
			}
		}
		
		return minResult;
	}

}
